/**
 * 
 */
package kr.pe.johnkim.dayve.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

/**
 * 설치 뒤 초기 데이터 다운로드 알림창을 띄우는 클래스이다.
 * 
 * 다운로드가 완료되면 자동으로 창을 닫는다.
 * 
 * @author johnkim
 *
 */
public class DayveInstallNotificationView extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);     
	    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	    getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
	            WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
	    
	    setContentView(R.layout.dayve_install_notification);

	    Thread thread = new Thread(null, doBackgroundThreadProcessing, "Background_insertLog");
		thread.start();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}
	
	/**
	 * 최초 설치 후 데이터 다운로드가 완료되면 자동으로 창을 닫는다.
	 */
	private Runnable doBackgroundThreadProcessing = new Runnable() {
		
		public void run() {
			// TODO Auto-generated method stub
			
			while(true) {
				try {
					Thread.sleep(100);

					if(
							(("SUCCESS").equals(DayveCategoryView.DOWNLOAD_CATEGORY_INITIAL_DATA))&&
							(("SUCCESS").equals(DayveCategoryView.DOWNLOAD_ITEM_INITIAL_DATA))&&
							(("SUCCESS").equals(DayveCategoryView.DOWNLOAD_ITEM_EVENT_INITIAL_DATA))&&
							(("SUCCESS").equals(DayveCategoryView.DOWNLOAD_FAVORITE_INITIAL_DATA))
							) {
						finish();
					}
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	};

}
